package com.jiuzhe.commercial.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jiuzhe.commercial.R;
import com.jiuzhe.commercial.bean.CountBean;

import java.util.List;

/**
 * Created by huanghao on 2018/5/8.
 */

public class CountListAdapter extends RecyclerView.Adapter<CountListAdapter.ViewHolder>{
    private Context context;
    private List<CountBean.SkuCountBean> skuCountBean;
    private CountBean.SkuCountBean skuCountBean1;

    public CountListAdapter(List<CountBean.SkuCountBean> list) {
        this.skuCountBean = list;
    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        this.context = parent.getContext();
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_count_item, parent, false);
        // 实例化viewholder
        ViewHolder viewHolder = new ViewHolder(v);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        skuCountBean1 = skuCountBean.get(position);
        holder.tvSkuName.setText(skuCountBean1.getSkuName());
        holder.tvSkuAvgPrice.setText(skuCountBean1.getSkuSumPrice());
        holder.tvOrderCount.setText(skuCountBean1.getOrderCount()+"");
        holder.tvSkuSumPrice.setText(skuCountBean1.getSkuSumPrice());
        holder.tvBrokerage.setText(skuCountBean1.getBrokerage()+"");
        holder.tvAdress.setText(skuCountBean1.getAddress());
        holder.tvNumber.setText((position + 1) + "");
    }


    @Override
    public int getItemCount() {
        return skuCountBean.size();
    }




    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView tvSkuName;
        TextView tvSkuAvgPrice;
        TextView tvOrderCount;
        TextView tvSkuSumPrice;
        TextView tvBrokerage;
        TextView tvAdress;
        TextView tvNumber;

        public ViewHolder(View v) {
            super(v);
            tvSkuName = (TextView) v.findViewById(R.id.tv_skuName);
            tvSkuAvgPrice = (TextView) v.findViewById(R.id.tv_skuAvgPrice);
            tvOrderCount = (TextView) v.findViewById(R.id.tv_orderCount);
            tvSkuSumPrice = (TextView) v.findViewById(R.id.tv_skuSumPrice);
            tvBrokerage = (TextView) v.findViewById(R.id.tv_brokerage);
            tvAdress = (TextView) v.findViewById(R.id.tv_adress);
            tvNumber = (TextView) v.findViewById(R.id.tv_number);
        }
    }
}
